.class public Lcom/nemustech/regina/WorkspaceView;
.super Landroid/view/ViewGroup;
.source "WorkspaceView.java"


# static fields
.field private static final TAG:Ljava/lang/String; = "WorkspaceView"


# instance fields
.field private mDebugBound:Z

.field private mDebugRect:Landroid/graphics/Rect;

.field private mReginaLauncher:Lcom/nemustech/regina/ReginaLauncher;

.field private mWsElementArrList:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList",
            "<",
            "Lcom/nemustech/regina/Element;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 1
    .parameter "context"

    .prologue
    .line 25
    const/4 v0, 0x0

    invoke-direct {p0, p1, v0}, Lcom/nemustech/regina/WorkspaceView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V

    .line 26
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
    .locals 1
    .parameter "context"
    .parameter "attrs"

    .prologue
    .line 29
    const/4 v0, 0x0

    invoke-direct {p0, p1, p2, v0}, Lcom/nemustech/regina/WorkspaceView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V

    .line 30
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V
    .locals 1
    .parameter "context"
    .parameter "attrs"
    .parameter "defStyle"

    .prologue
    .line 33
    invoke-direct {p0, p1, p2, p3}, Landroid/view/ViewGroup;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V

    .line 22
    new-instance v0, Landroid/graphics/Rect;

    invoke-direct {v0}, Landroid/graphics/Rect;-><init>()V

    iput-object v0, p0, Lcom/nemustech/regina/WorkspaceView;->mDebugRect:Landroid/graphics/Rect;

    .line 34
    invoke-direct {p0}, Lcom/nemustech/regina/WorkspaceView;->init()V

    .line 35
    return-void
.end method

.method private init()V
    .locals 1

    .prologue
    const/4 v0, 0x0

    .line 38
    iput-boolean v0, p0, Lcom/nemustech/regina/WorkspaceView;->mDebugBound:Z

    .line 39
    invoke-virtual {p0, v0}, Lcom/nemustech/regina/WorkspaceView;->setWillNotDraw(Z)V

    .line 40
    return-void
.end method


# virtual methods
.method public dispatchDisplayVisibility(Z)V
    .locals 4
    .parameter "visibility"

    .prologue
    .line 52
    invoke-virtual {p0}, Lcom/nemustech/regina/WorkspaceView;->getChildCount()I

    move-result v0

    .line 53
    .local v0, childCount:I
    const/4 v1, 0x0

    .local v1, index:I
    :goto_0
    if-ge v1, v0, :cond_1

    .line 54
    invoke-virtual {p0, v1}, Lcom/nemustech/regina/WorkspaceView;->getChildAt(I)Landroid/view/View;

    move-result-object v2

    .line 55
    .local v2, view:Landroid/view/View;
    instance-of v3, v2, Lcom/nemustech/regina/ReginaAppWidgetHostView;

    if-eqz v3, :cond_0

    .line 56
    check-cast v2, Lcom/nemustech/regina/ReginaAppWidgetHostView;

    .end local v2           #view:Landroid/view/View;
    invoke-virtual {v2, p1}, Lcom/nemustech/regina/ReginaAppWidgetHostView;->onDisplayVisibilityChanged(Z)V

    .line 53
    :cond_0
    add-int/lit8 v1, v1, 0x1

    goto :goto_0

    .line 59
    :cond_1
    return-void
.end method

.method protected dispatchDraw(Landroid/graphics/Canvas;)V
    .locals 13
    .parameter "canvas"

    .prologue
    .line 100
    invoke-super {p0, p1}, Landroid/view/ViewGroup;->dispatchDraw(Landroid/graphics/Canvas;)V

    .line 102
    iget-boolean v9, p0, Lcom/nemustech/regina/WorkspaceView;->mDebugBound:Z

    if-eqz v9, :cond_1

    .line 103
    new-instance v7, Landroid/graphics/Paint;

    const/4 v9, 0x1

    invoke-direct {v7, v9}, Landroid/graphics/Paint;-><init>(I)V

    .line 105
    .local v7, paint:Landroid/graphics/Paint;
    const/4 v9, -0x1

    invoke-virtual {v7, v9}, Landroid/graphics/Paint;->setColor(I)V

    .line 106
    sget-object v9, Landroid/graphics/Paint$Style;->STROKE:Landroid/graphics/Paint$Style;

    invoke-virtual {v7, v9}, Landroid/graphics/Paint;->setStyle(Landroid/graphics/Paint$Style;)V

    .line 108
    iget-object v9, p0, Lcom/nemustech/regina/WorkspaceView;->mWsElementArrList:Ljava/util/ArrayList;

    invoke-virtual {v9}, Ljava/util/ArrayList;->size()I

    move-result v6

    .line 109
    .local v6, len:I
    const/4 v5, 0x0

    .local v5, i:I
    :goto_0
    if-ge v5, v6, :cond_1

    .line 110
    iget-object v9, p0, Lcom/nemustech/regina/WorkspaceView;->mWsElementArrList:Ljava/util/ArrayList;

    invoke-virtual {v9, v5}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/nemustech/regina/Element;

    .line 111
    .local v0, e:Lcom/nemustech/regina/Element;
    if-eqz v0, :cond_0

    .line 112
    iget-object v8, p0, Lcom/nemustech/regina/WorkspaceView;->mDebugRect:Landroid/graphics/Rect;

    .line 114
    .local v8, rect:Landroid/graphics/Rect;
    iget-object v9, p0, Lcom/nemustech/regina/WorkspaceView;->mReginaLauncher:Lcom/nemustech/regina/ReginaLauncher;

    invoke-virtual {v0}, Lcom/nemustech/regina/Element;->getX()F

    move-result v10

    invoke-static {v9, v10}, Lcom/nemustech/regina/RUtils;->convertTo2DPosX(Landroid/content/Context;F)I

    move-result v3

    .line 115
    .local v3, elementX:I
    iget-object v9, p0, Lcom/nemustech/regina/WorkspaceView;->mReginaLauncher:Lcom/nemustech/regina/ReginaLauncher;

    invoke-virtual {v0}, Lcom/nemustech/regina/Element;->getY()F

    move-result v10

    invoke-static {v9, v10}, Lcom/nemustech/regina/RUtils;->convertTo2DPosY(Landroid/content/Context;F)I

    move-result v4

    .line 116
    .local v4, elementY:I
    iget-object v9, p0, Lcom/nemustech/regina/WorkspaceView;->mReginaLauncher:Lcom/nemustech/regina/ReginaLauncher;

    invoke-virtual {v0}, Lcom/nemustech/regina/Element;->getWidth3D()F

    move-result v10

    invoke-static {v9, v10}, Lcom/nemustech/regina/RUtils;->convertTo2DSize(Landroid/content/Context;F)I

    move-result v2

    .line 117
    .local v2, elementWidth:I
    iget-object v9, p0, Lcom/nemustech/regina/WorkspaceView;->mReginaLauncher:Lcom/nemustech/regina/ReginaLauncher;

    invoke-virtual {v0}, Lcom/nemustech/regina/Element;->getHeight3D()F

    move-result v10

    invoke-static {v9, v10}, Lcom/nemustech/regina/RUtils;->convertTo2DSize(Landroid/content/Context;F)I

    move-result v1

    .line 119
    .local v1, elementHeight:I
    div-int/lit8 v9, v2, 0x2

    sub-int v9, v3, v9

    div-int/lit8 v10, v1, 0x2

    sub-int v10, v4, v10

    div-int/lit8 v11, v2, 0x2

    add-int/2addr v11, v3

    div-int/lit8 v12, v1, 0x2

    add-int/2addr v12, v4

    invoke-virtual {v8, v9, v10, v11, v12}, Landroid/graphics/Rect;->set(IIII)V

    .line 121
    invoke-virtual {p1, v8, v7}, Landroid/graphics/Canvas;->drawRect(Landroid/graphics/Rect;Landroid/graphics/Paint;)V

    .line 109
    .end local v1           #elementHeight:I
    .end local v2           #elementWidth:I
    .end local v3           #elementX:I
    .end local v4           #elementY:I
    .end local v8           #rect:Landroid/graphics/Rect;
    :cond_0
    add-int/lit8 v5, v5, 0x1

    goto :goto_0

    .line 125
    .end local v0           #e:Lcom/nemustech/regina/Element;
    .end local v5           #i:I
    .end local v6           #len:I
    .end local v7           #paint:Landroid/graphics/Paint;
    :cond_1
    return-void
.end method

.method protected onLayout(ZIIII)V
    .locals 10
    .parameter "changed"
    .parameter "l"
    .parameter "t"
    .parameter "r"
    .parameter "b"

    .prologue
    .line 63
    invoke-virtual {p0}, Lcom/nemustech/regina/WorkspaceView;->getChildCount()I

    move-result v5

    .line 64
    .local v5, count:I
    const/4 v7, 0x0

    .local v7, i:I
    :goto_0
    if-ge v7, v5, :cond_1

    .line 65
    invoke-virtual {p0, v7}, Lcom/nemustech/regina/WorkspaceView;->getChildAt(I)Landroid/view/View;

    move-result-object v0

    .line 66
    .local v0, child:Landroid/view/View;
    invoke-virtual {v0}, Landroid/view/View;->getVisibility()I

    move-result v8

    const/16 v9, 0x8

    if-eq v8, v9, :cond_0

    .line 67
    invoke-virtual {v0}, Landroid/view/View;->getTag()Ljava/lang/Object;

    move-result-object v6

    check-cast v6, Lcom/nemustech/regina/ElementAndroidWidget;

    .line 68
    .local v6, element:Lcom/nemustech/regina/ElementAndroidWidget;
    invoke-virtual {v6}, Lcom/nemustech/regina/ElementAndroidWidget;->getWidth2D()I

    move-result v4

    .line 69
    .local v4, childWidth:I
    invoke-virtual {v6}, Lcom/nemustech/regina/ElementAndroidWidget;->getHeight2D()I

    move-result v1

    .line 70
    .local v1, childHeight:I
    invoke-virtual {v6}, Lcom/nemustech/regina/ElementAndroidWidget;->getLeft2D()I

    move-result v2

    .line 71
    .local v2, childLeft:I
    invoke-virtual {v6}, Lcom/nemustech/regina/ElementAndroidWidget;->getTop2D()I

    move-result v3

    .line 73
    .local v3, childTop:I
    add-int v8, v2, v4

    add-int v9, v3, v1

    invoke-virtual {v0, v2, v3, v8, v9}, Landroid/view/View;->layout(IIII)V

    .line 64
    .end local v1           #childHeight:I
    .end local v2           #childLeft:I
    .end local v3           #childTop:I
    .end local v4           #childWidth:I
    .end local v6           #element:Lcom/nemustech/regina/ElementAndroidWidget;
    :cond_0
    add-int/lit8 v7, v7, 0x1

    goto :goto_0

    .line 79
    .end local v0           #child:Landroid/view/View;
    :cond_1
    return-void
.end method

.method protected onMeasure(II)V
    .locals 8
    .parameter "widthMeasureSpec"
    .parameter "heightMeasureSpec"

    .prologue
    const/high16 v7, 0x4000

    .line 83
    invoke-virtual {p0}, Lcom/nemustech/regina/WorkspaceView;->getChildCount()I

    move-result v3

    .line 84
    .local v3, count:I
    const/4 v5, 0x0

    .local v5, i:I
    :goto_0
    if-ge v5, v3, :cond_0

    .line 85
    invoke-virtual {p0, v5}, Lcom/nemustech/regina/WorkspaceView;->getChildAt(I)Landroid/view/View;

    move-result-object v0

    .line 86
    .local v0, child:Landroid/view/View;
    invoke-virtual {v0}, Landroid/view/View;->getTag()Ljava/lang/Object;

    move-result-object v4

    check-cast v4, Lcom/nemustech/regina/ElementAndroidWidget;

    .line 88
    .local v4, element:Lcom/nemustech/regina/ElementAndroidWidget;
    invoke-virtual {v4}, Lcom/nemustech/regina/ElementAndroidWidget;->getWidth2D()I

    move-result v6

    invoke-static {v6, v7}, Landroid/view/View$MeasureSpec;->makeMeasureSpec(II)I

    move-result v1

    .line 90
    .local v1, childWidthMeasureSpec:I
    invoke-virtual {v4}, Lcom/nemustech/regina/ElementAndroidWidget;->getHeight2D()I

    move-result v6

    invoke-static {v6, v7}, Landroid/view/View$MeasureSpec;->makeMeasureSpec(II)I

    move-result v2

    .line 92
    .local v2, childheightMeasureSpec:I
    invoke-virtual {v0, v1, v2}, Landroid/view/View;->measure(II)V

    .line 84
    add-int/lit8 v5, v5, 0x1

    goto :goto_0

    .line 95
    .end local v0           #child:Landroid/view/View;
    .end local v1           #childWidthMeasureSpec:I
    .end local v2           #childheightMeasureSpec:I
    .end local v4           #element:Lcom/nemustech/regina/ElementAndroidWidget;
    :cond_0
    invoke-super {p0, p1, p2}, Landroid/view/ViewGroup;->onMeasure(II)V

    .line 96
    return-void
.end method

.method public setDebugBound(ZLcom/nemustech/regina/RGWorkspace;)V
    .locals 1
    .parameter "show"
    .parameter "currentWorkspace"

    .prologue
    .line 47
    iput-boolean p1, p0, Lcom/nemustech/regina/WorkspaceView;->mDebugBound:Z

    .line 48
    invoke-virtual {p2}, Lcom/nemustech/regina/RGWorkspace;->getElementList()Ljava/util/ArrayList;

    move-result-object v0

    iput-object v0, p0, Lcom/nemustech/regina/WorkspaceView;->mWsElementArrList:Ljava/util/ArrayList;

    .line 49
    return-void
.end method

.method public setMainActivity(Lcom/nemustech/regina/ReginaLauncher;)V
    .locals 0
    .parameter "mainActivity"

    .prologue
    .line 43
    iput-object p1, p0, Lcom/nemustech/regina/WorkspaceView;->mReginaLauncher:Lcom/nemustech/regina/ReginaLauncher;

    .line 44
    return-void
.end method
